package service;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;

import dao.MyclassDAO;
import dao.StudentDAO;
import dao.TeacherDAO;
import pojo.Myclass;
import pojo.Teacher;

public class ClassService {
	private MyclassDAO myclassDAO;
	private StudentDAO studentDAO;
	private TeacherDAO teacherDAO;
	public List<Myclass> getClassList(String teacherUserName){
		List list = myclassDAO.findByTeacherUserName(teacherUserName),
				resList = new ArrayList();
		Iterator it = list.iterator();
		while(it.hasNext()){
			Myclass temp = (Myclass) it.next();
			temp = getClassInfo(temp.getMyClassId());
			resList.add(temp);
		}
		return resList;
	}
	
	public Myclass getClassInfo(int classId){
		Myclass res = myclassDAO.findById(classId);
		res.setStudents(new HashSet(studentDAO.findByClassId(classId)));
		return res;
	}

	public MyclassDAO getMyclassDAO() {
		return myclassDAO;
	}

	public void setMyclassDAO(MyclassDAO myclassDAO) {
		this.myclassDAO = myclassDAO;
	}

	public StudentDAO getStudentDAO() {
		return studentDAO;
	}

	public void setStudentDAO(StudentDAO studentDAO) {
		this.studentDAO = studentDAO;
	}

	public TeacherDAO getTeacherDAO() {
		return teacherDAO;
	}

	public void setTeacherDAO(TeacherDAO teacherDAO) {
		this.teacherDAO = teacherDAO;
	}

}
